﻿#ifndef BOOKWIDGET_H
#define BOOKWIDGET_H

#include <QListWidget>
#include <QWidget>
#include "historyrecord.h"
#include <QDebug>

namespace Ui {
class BookMarkWidget;
}

class BookMarkWidget : public QWidget
{
    Q_OBJECT

public:
    explicit BookMarkWidget(QWidget *parent = nullptr);
    ~BookMarkWidget();
    void showEvent(QShowEvent *event) override;
    void updateBookMarkData(QDateTime startTime = QDateTime::currentDateTime().addYears(-10));
    void reloadHistoryData();

    static bool caseInsensitiveLessThan(const HistoryRecord &s1, const HistoryRecord &s2);

    static QString m_bookMarkFile;

    bool checkCollected(QString url);

private slots:
    void handleItemClick(QListWidgetItem *item);
    void handleItemDoubleClick(QListWidgetItem *item);

public slots:
    void addBookMark(QString url);

signals:
    void loadUrl(QString url);
    void urlCollected(bool state);

private:
    Ui::BookMarkWidget *ui;
    QVector<HistoryRecord> m_historyRecord;

    // 加快查询
    QMap<QString, int> mp;

};

#endif // BOOKWIDGET_H
